xim: Stop using gdk_surface_get_user_data
authorMatthias Clasen <mclasen@redhat.com>
Sat, 23 Feb 2019 21:52:51 +0000 (16:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 24 Feb 2019 03:24:50 +0000 (22:24 -0500)
Use gtk_root_get_for_surface instead.

gtk/gtkimcontextxim.c

index c93fcc34b2d3d1b4c8db09fbc18df9b8d2f5496e..98f6e530a6ccee61258ee856472aa27637b18bfa 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "gtkimcontextxim.h"
 #include "gtkimmoduleprivate.h"
+#include "gtkroot.h"
 
 #include "gtk/gtkintl.h"
 
@@ -1526,32 +1527,16 @@ on_client_widget_hierarchy_changed (GtkWidget       *widget,
   update_in_toplevel (context_xim);
 }
 
-/* Finds the GtkWidget that owns the window, or if none, the
- * widget owning the nearest parent that has a widget.
- */
-static GtkWidget *
-widget_for_window (GdkSurface *window)
-{
-  while (window)
-    {
-      gpointer user_data;
-      gdk_surface_get_user_data (window, &user_data);
-      if (user_data)
-       return user_data;
-
-      window = gdk_surface_get_parent (window);
-    }
-
-  return NULL;
-}
-
 /* Called when context_xim->client_surface changes; takes care of
  * removing and/or setting up our watches for the toplevel
  */
 static void
 update_client_widget (GtkIMContextXIM *context_xim)
 {
-  GtkWidget *new_client_widget = widget_for_window (context_xim->client_surface);
+  GtkWidget *new_client_widget = NULL;
+
+  if (context_xim->client_surface)
+    new_client_widget = gtk_root_get_for_surface (context_xim->client_surface);
 
   if (new_client_widget != context_xim->client_widget)
     {